<template>
  <div class="user-detail">
    <div>
      <div class="user-img">
        <img v-if="userInfo.user_img" :src="userInfo.user_img" alt="">
        <img v-else src="@/assets/default_img.jpg" alt="">
      </div>
      <div class="user-edit">
        <div>
          <p>
            <span>0</span>
            <span class="user-text">粉丝</span>
          </p>
          <p>
            <span>54</span>
            <span class="user-text">关注</span>
          </p>
          <p>
            <span>0</span>
            <span class="user-text">获赞</span>
          </p>
        </div>
        <div @click="$router.push('/edit')">
          <div class="user-edit-button">编辑资料</div>
        </div>
      </div>
    </div>
    <div>
      <h2>{{ userInfo.name }}</h2>
      <p v-if="userInfo.user_desc">{{ userInfo.user_desc }}</p>
      <p v-else>这个人很神秘，什么都没写</p>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    userInfo: {
      default: () => ({}),
      type: Object
    }
  }
}
</script>

<style lang="scss" scoped>
.user-detail {
  background-color: white;
  padding: 7px 12px;
  >div:nth-child(1) {
    display: flex;
    justify-content: center;
    align-items: center;
    .user-img {
      margin-right: 20px;
      img {
        width: 85px;
        height: 85px;
        border-radius: 50%;
      }
    }
    .user-edit {
      flex: 1;
      div:nth-child(1) {
        display: flex;
        p {
          flex: 1;
          display: flex;
          justify-content: center;
          align-items: center;
          flex-direction: column;
          font-size: 13px;
        }
        p:nth-child(1), p:nth-child(2) {
          border-right: 1px solid #ccc; 
        }
        .user-text {
          color: #aaa;
        }
      }
      div:nth-child(2) {
        padding: 5px 10px;
        .user-edit-button {
          border: 1px solid #fb7a9f;
          display: flex;
          justify-content: center;
          align-items: center;
          color: #fb7a9f;
          padding: 3px;
          border-radius: 4px;
        }
      }
    }
  }
  >div:nth-child(2) {
    h2 {
      margin: 10px 0px 3px 0px;
      font-weight: 400;
    }
    p {
      padding: 0;
      margin: 10px 0;
      color: #999;
    }
  }
}
</style>